﻿#include "RevivingZombie.h"
#include "../../../Shared/Data/Stat.h"

using namespace Server::MirDatabase;
namespace S = ServerPackets;

namespace Server::MirObjects::Monsters
{

    unsigned int RevivingZombie::getExperience() const
    {
        return static_cast<unsigned int>(Info->Experience * (100 - (25 * RevivalCount)) / 100);
    }

    RevivingZombie::RevivingZombie(MonsterInfo *info) : MonsterObject(info)
    {
        RevivalCount = 0;
        LifeCount = getEnvir()->Random->Next(3);
    }

    void RevivingZombie::Die()
    {
        DieTime = getEnvir()->getTime();
        RevivalTime = (4 + getEnvir()->Random->Next(20)) * 1000;
        MonsterObject::Die();
    }

    void RevivingZombie::ProcessAI()
    {
        if (Dead && getEnvir()->getTime() > DieTime + RevivalTime && RevivalCount < LifeCount)
        {
            RevivalCount++;

            int newhp = Stats[Stat::HP] * (100 - (25 * RevivalCount)) / 100;
            Revive(newhp, false);
        }

        MonsterObject::ProcessAI();
    }
}
